package leetcode_2101_2200;

public class LeeCode_2172 {
    public static void main(String[] args) {

    }
    private static int maximumANDSum(int[] nums, int numSlots) {
        int n = numSlots * 2, m = nums.length, max = 1 << n, ans = 0;
        int[] dp = new int[1 << n];
        for (int i = 0; i < max; i++) {
            int c = Integer.bitCount(i);
            if (c >= m)
                continue;
            for (int j = 0; j < n; j++) {
                if ((i & (1 << j)) == 0){
                    int s = i | (1 << j);
                    dp[s] = Math.max(dp[s], dp[i] + (nums[c] & (j / 2 + 1)));
                    ans = Math.max(dp[s], ans);
                }
            }
        }
        return ans;
    }
}